import type {IColumnsOption} from 'vc';
import {
  INDEX,
} from '@/utils/tableColumn';

export function useTable() {
  const columns = ref<IColumnsOption[]>([
    {...INDEX},
    {
      field: 'addTime',
      title: '披露日期',
      align: 'center',
      // sortable: true,
      width: 120,
      sortBy: 'addTime',
      formatter: ({row}) => {
        return row.addTime ? row.addTime.split(" ")[0] : '-';
      }
    },
    {
      field: 'noMonitoringItemsType',
      title: '不监测类型',
      align: 'center',
      // sortable: true,
      width: 120,
      sortBy: 'noMonitoringItemsType',
    },
    {
      field: 'noMonitoringItem',
      title: '不监测名称',
      align: 'center',
      // sortable: true,
      width: 120,
      sortBy: 'noMonitoringItem',
    },
    {
      field: 'beginDate',
      title: '开始日期',
      align: 'center',
      // sortable: true,
      width: 120,
      sortBy: 'beginDate',
      formatter: ({row}) => {
        return row.beginDate ? row.beginDate.split(" ")[0] : '-';
      }
    },
    {
      field: 'expirationDate',
      title: '截止日期',
      align: 'center',
      // sortable: true,
      width: 120,
      sortBy: 'expirationDate',
      formatter: ({row}) => {
        return row.expirationDate ? row.expirationDate.split(" ")[0] : '-';
      }
    },
    {
      field: 'monitoringType',
      title: '监测方式',
      align: 'center',
      // sortable: true,
      width: 120,
      sortBy: 'monitoringType',
    },
    {
      field: 'tagStopProduction',
      title: '是否停产',
      align: 'center',
      // sortable: true,
      width: 120,
      sortBy: 'tagStopProduction',
      slots: {
        default: ({row}) => {
          return <>
            {row.tagStopProduction ?
              <span style={{color: '#fff', background: '#FB9196', padding: '2px 4px'}}>
                是
              </span> :
              <span style={{color: '#fff', background: '#2CD8C5', padding: '2px 4px'}}>否</span>}
          </>;
        }
      }
    },
    {
      field: 'noMonitoringReason',
      title: '不监测原因',
      showOverflow: 'title'
    },
  ]);

  return {
    columns
  };
}
